package com.wsj.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;

import com.wsj.dao.IDirectSeedNameDao;
import com.wsj.service.IDirectSeedNameServ;
import com.wsj.util.exception.BusinessException;
import com.wsj.util.page.PageResultSet;
import com.wsj.web.vo.homeSite.DirectSeedName;

public class DirectSeedNameServImpl implements IDirectSeedNameServ {

	private IDirectSeedNameDao directSeedNameDao;
	
	public void add(DirectSeedName directSeedName) throws BusinessException {
		this.directSeedNameDao.add(directSeedName);
	}

	//  检查 直播名是否被占用 true 被占用
	public boolean checkName(String name) throws BusinessException {
		DirectSeedName d = new DirectSeedName();
		d = this.loadByName(name);
		if(d==null){
			return false;
		}
		return true;
	}

	public void delete(DirectSeedName directSeedName) throws BusinessException {
		this.directSeedNameDao.delete(directSeedName);
	}


	public void update(DirectSeedName directSeedName) throws BusinessException {
		this.directSeedNameDao.update(directSeedName);
	}

	public List<DirectSeedName> loadAll() throws BusinessException {
		return this.directSeedNameDao.loadAll();
	}

	public DirectSeedName loadById(Integer id) throws BusinessException {
		DirectSeedName d = new DirectSeedName();
		if(id!=null && !(new Integer(0)).equals(id)){
			d = this.directSeedNameDao.loadById(id); 
		}
		return d;
	}

	public DirectSeedName loadByName(String name) throws BusinessException {
		DirectSeedName d = new DirectSeedName();
		if(name!=null && !"".equals(name)){
			d = this.directSeedNameDao.loadByName(name);
		}
		return d;
	}

	public PageResultSet loadPageList(String keyWord, String name,
			Short iscommend,Short del,String beginDate, String endDate, Integer page,
			Integer pageSize) throws BusinessException {
		return this.directSeedNameDao.loadPageList(keyWord, name, iscommend, del, beginDate, endDate, page, pageSize);
	}

	public IDirectSeedNameDao getDirectSeedNameDao() {
		return directSeedNameDao;
	}

	public void setDirectSeedNameDao(IDirectSeedNameDao directSeedNameDao) {
		this.directSeedNameDao = directSeedNameDao;
	}

	public List loadDirectSeedNameByInputtime(String year) throws DataAccessException {
		return this.directSeedNameDao.loadDirectSeedNameByInputtime(year);
	}

	public Map<String, String> loadDirectSeedNameMapByInputtime(String year) throws BusinessException {
		Map<String,String> map = new HashMap<String,String>(); 
		List list=this.directSeedNameDao.loadDirectSeedNameByInputtime(year);
		if(list!=null&&list.size()>0){
			for(int i=0; i<list.size(); i++){
				DirectSeedName directSeedName=(DirectSeedName) list.get(i);
				if(directSeedName!=null){
					map.put(directSeedName.getId().toString(), directSeedName.getQiname());
				}
				
			}
		}
		return map;
	}

	public DirectSeedName getZuiXinTopDirectSeedName(int top) throws BusinessException {
		// TODO Auto-generated method stub
		DirectSeedName directSeedName=this.directSeedNameDao.getZuiXinTopDirectSeedName(top);
	
		return directSeedName;
	}

	public List getTopDirectSeedName(int top, Integer sameId) throws BusinessException {
		// TODO Auto-generated method stub
		
		List list=this.directSeedNameDao.getTopDirectSeedName(top,sameId);
		
		return list;
	}

	public DirectSeedName getzuixinDSeedName() throws BusinessException {
		// TODO Auto-generated method stub
		DirectSeedName directSeedName=this.directSeedNameDao.getzuixinDSeedName();
		
		return directSeedName;
	}

	public List getTopByZxinDirectSeedName(Integer zxinDSeedNameid, int top) {
		// TODO Auto-generated method stub
		List list=this.directSeedNameDao.getTopByZxinDirectSeedName(zxinDSeedNameid,top);
		
		return list;
	}

	
}
